import socket
tcp_server = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
tcp_server.bind(('',8007))
tcp_server.listen()
socket,addr = tcp_server.accept()
while True:
    data = socket.recv(1024)
    print(data.decode('utf-8'))
    mess = input('请输入你要发送的数据：')
    if mess:
        socket.send(mess.encode('utf-8'))
    else:
        break
socket.close()
tcp_server.close()